package com.maopuyu.template;

import com.maopuyu.entity.EnglishItem;
import com.maopuyu.services.EnglishItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


@Controller
public class IndexController {

    @Autowired
    private EnglishItemService englishItemService;

    @GetMapping("/itemDetail")
    public String detail(@RequestParam("id") Integer id, Model model) {
        return "build/detail";
    }

    @GetMapping("")
    public String englishItems(Model model){
        List<EnglishItem> itemList = englishItemService.findAll();
        model.addAttribute("items", itemList);
        return "build/index";
    }
}
